//
//  HWSplitTagLabel.swift
//  HWanGame
//
//  Created by 王昌健 on 2023/11/10.
//  Copyright © 2023 94Wan. All rights reserved.
//

import UIKit

class HWSplitTagLabel: UIView {
    
    var leftBgView:UIView!
    var leftLabel:UILabel!
    var rightLabel:UILabel!
    var title:NSString?{
        didSet{
            
        }
    }
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        initUI()
        
        initFrame()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func initUI() -> Void {
        backgroundColor = .colorWithHexString(hexString: "#FFE6E5")
        layer.cornerRadius = 7*widthScale
        layer.masksToBounds = true
        
        leftBgView = UIView()
        leftBgView.backgroundColor = .colorWithHexString(hexString: "#FFD3D1")
        addSubview(leftBgView)
        
        leftLabel = HWLabel.createLabel(title: "充值", color: "#FF726A", font: 9*widthScale)
        leftLabel.font = .systemFont(ofSize: 9*widthScale, weight: .semibold)
        leftBgView.addSubview(leftLabel)
        
        rightLabel = HWLabel.createLabel(title: "1:000代金券", color: "#FF726A", font: 9*widthScale)
        rightLabel.font = .systemFont(ofSize: 9*widthScale, weight: .semibold)
        addSubview(rightLabel)
        
    }
    
    private func initFrame() -> Void {
        
        leftBgView.snp.makeConstraints { make in
            make.left.top.bottom.equalToSuperview().priority(.high)
        }
        
        leftLabel.snp.makeConstraints { make in
            make.left.equalTo(4*widthScale)
            make.right.equalTo(-4*widthScale)

            make.top.bottom.equalToSuperview()
        }
        
        rightLabel.snp.makeConstraints { make in
            make.left.equalTo(leftBgView.snp.right).offset(4*widthScale)
            make.right.equalTo(-7*widthScale)
            make.top.bottom.equalToSuperview()
        }
        
        leftLabel.setContentHuggingPriority(.required, for: .horizontal)
        rightLabel.setContentHuggingPriority(.required, for: .horizontal)
    }
}
